import request from '../request/request';

// 创建任务
export const createTask = async (data: any) => {
  return await request.post('/task/create', data);
};

// 获取任务列表
export const getTaskList = async (params: any) => {
  return await request.get('/task/list', { params });
};

// 获取任务详情
export const getTaskDetail = async (taskId: number) => {
  return await request.get(`/task/detail/${taskId}`);
};

// 更新任务
export const updateTask = async (data: any) => {
  return await request.put('/task/update', data);
};

// 删除任务
export const deleteTask = async (taskId: number) => {
  return await request.delete(`/task/delete/${taskId}`);
};

// 更新任务状态
export const updateTaskStatus = async (taskId: number, status: number) => {
  return await request.put('/task/updateStatus', { taskId, status });
};

// 更新任务进度
export const updateTaskProgress = async (taskId: number, progress: number) => {
  return await request.put('/task/updateProgress', { taskId, progress });
};

// 获取任务评论
export const getTaskComments = async (taskId: number) => {
  return await request.get(`/task/comment/${taskId}`);
};

// 添加任务评论
export const addTaskComment = async (data: any) => {
  return await request.post('/task/comment/add', data);
};

// 删除任务评论
export const deleteTaskComment = async (commentId: number) => {
  return await request.delete(`/task/comment/delete/${commentId}`);
};

// 获取我的任务
export const getMyTasks = async (params: any) => {
  return await request.get('/task/myTasks', { params });
};

// 获取队伍任务
export const getTeamTasks = async (teamId: number, params: any) => {
  return await request.get(`/task/team/${teamId}`, { params });
};

// 任务分配
export const assignTask = async (taskId: number, assigneeUid: string) => {
  return await request.put('/task/assign', { taskId, assigneeUid });
};